<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">
    <h:head>
    </h:head>
    <h:body>
        <ui:composition template="WEB-INF/facelets/Template.xhtml">
            <ui:define name="content">
                <center>
                    Browse category: <h:form><h:selectOneMenu style="color: #FFFFFF; background-color: #000000" value="#{BrowseBean.category}">
                            <f:selectItems
                                value="#{SupportBean.categories}" />

                        </h:selectOneMenu>
                        <h:commandButton id="btnOK" value="Change"
                                         actionListener="#{BrowseBean.changeCategory}" /></h:form> <br/>
                    <h:form>

                        <p:panel>
                            <h:panelGrid columns="1" cellpadding="5">

                                <p:dataTable var="torrent" value="#{BrowseBean.result}"
                                             paginator="true" rows="10"
                                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                             rowsPerPageTemplate="5,10,15,20">
                                    <f:facet name="header">
                                    </f:facet>

                                    <p:column sortBy="#{torrent.name}">
                                        <f:facet name="header">
                                            <h:outputText value="Name" />
                                        </f:facet>
                                        <h:commandLink id="viewDetails" action="#{SearchBean.viewDetails(torrent)}" value="#{torrent.name}"/>
                                    </p:column>

                                    <p:column sortBy="#{torrent.date}">
                                        <f:facet name="header">
                                            <h:outputText value="Uploaded" />
                                        </f:facet>
                                        <h:outputText value="#{torrent.date}" />
                                    </p:column>

                                    <p:column sortBy="#{torrent.size}">
                                        <f:facet name="header">
                                            <h:outputText value="Size" />
                                        </f:facet>
                                        <h:outputText value="#{torrent.size}" />
                                    </p:column>

                                    <p:column sortBy="#{torrent.user.username}">
                                        <f:facet name="header">
                                            <h:outputText value="User" />
                                        </f:facet>
                                        <h:outputText value="#{torrent.user.username}" />
                                    </p:column>

                                    <p:column rendered="#{UserBean.user.rank == 'ADMIN'}">
                                        <f:facet name="header">
                                            <h:outputText value="Delete" />
                                        </f:facet>
                                        <h:commandLink id="delete" action="#{SearchBean.delete(torrent)}">X</h:commandLink>
                                    </p:column>
                                </p:dataTable>
                            </h:panelGrid>
                        </p:panel>
                    </h:form>
                </center>
            </ui:define>
        </ui:composition>

    </h:body>
</html>

